package cn.edu.ctbu.myblog.service;

import cn.edu.ctbu.myblog.dao.CommentDAO;
import cn.edu.ctbu.myblog.domain.ArticleDO;
import cn.edu.ctbu.myblog.domain.CommentDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.Date;
import java.util.List;

@Service
public class CommentService {

    @Autowired
    CommentDAO commentDAO;



    public List<CommentDO> getAll(){
        List<CommentDO> commentDOS=commentDAO.findAll();
        return commentDOS;
    }

    public List<CommentDO> getById(int id){
        List<CommentDO> commentDOS=commentDAO.findById(id);
        return commentDOS;
    }

    public void addComment(String comment, int userId, int articleId){
        Date nowDate = new Date();
        commentDAO.addComment(userId,articleId,comment,nowDate);
    }

}
